package com.school.HomeWork.ada.Adapter;



public class Client {
    public static void main(String[] args) {
        CarController carController = new AmbulanceAdapter();
        carController.move();
        carController.phonate();
        carController.twinkle();
    }
}
// 抽象目标
abstract class CarController {
    public void move() {
        System.out.println("玩具汽车移动!");
    }
    public abstract void phonate();
    public abstract void twinkle();
}

// 适配者
class AmbulanceLamp {
    public void lighting() {
        System.out.println("救护车灯光闪烁！");
    }
}

// 适配者
class AmbulanceSound {
    public void sounding() {
        System.out.println("救护车声音响起！");
    }
}


// 适配器
class AmbulanceAdapter extends CarController {
    private AmbulanceLamp lamp;
    private AmbulanceSound sound;

    public AmbulanceAdapter() {
        this.lamp = new AmbulanceLamp();
        this.sound = new AmbulanceSound();
    }

    @Override
    public void phonate() {
        sound.sounding();
    }

    @Override
    public void twinkle() {
        lamp.lighting();
    }
}



